#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int big = 0;
    for (int i = 1; i <= n; i++){
        long long a;
        cin >> a;
        int sum = 0;
        while (a > 0){
            int wei = a % 10;
            sum += wei;
            a = a / 10;
        }
        if (sum >= big) big = sum;
    }
    cout << big;
    return 0;
}